<%--
功能：获取指定目录下或者指定文章(可多个)的关联文章
--%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ tag import="java.util.List" %>
<%@ tag import="java.util.ArrayList" %>
<%@ tag import="org.springframework.context.ApplicationContext" %>
<%@ tag import="org.springframework.web.context.support.WebApplicationContextUtils" %>
<%@ tag import="org.apache.commons.lang.ArrayUtils" %>
<%@ tag import="com.probiz.estore.content.service.EvalRelatedContentManager" %>
<%@ tag import="com.probiz.estore.content.service.ContentRelatedTypeManager" %>
<%@ tag import="com.probiz.estore.common.model.content.Content" %>
<%@ tag import="com.probiz.estore.common.model.content.ContentRelatedType" %>

<%@ attribute name="relatedTypeName" type="java.lang.String" required="true" description="关联类型的名称，如keywords,newest,viewCount等等" %>
<%@ attribute name="sourceKind" type="java.lang.Integer" required="true" description="源类型，0是文章，1是目录" %>
<%@ attribute name="sourceId" type="java.lang.Integer" required="true" description="源id(文章id或者文章目录id)" %>
<%@ attribute name="firstResult" type="java.lang.Integer" required="false" description="第一条记录起始序号，默认为0" %>
<%@ attribute name="maxResults" type="java.lang.Integer" required="false" description="最多获取记录条数" %>

<%@ attribute name="returnContentListName" type="java.lang.String" required="true" description="要返回的关联文章列表名称" %>
<%@ attribute name="returnRelatedTypeName" type="java.lang.String" required="true" description="要返回的关联类型实体名称" %>

<%

	ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(session.getServletContext());
	EvalRelatedContentManager evalRelatedContentManager = (EvalRelatedContentManager) ctx.getBean("evalRelatedContentManager");
	ContentRelatedTypeManager contentRelatedTypeManager = (ContentRelatedTypeManager) ctx.getBean("contentRelatedTypeManager");
	
	if(null==firstResult)firstResult = 0;
	if(null==maxResults)maxResults = -1;
	try{
		List<Content> contentList = evalRelatedContentManager.getContentsByRecommendedTypeNameBySourceId(relatedTypeName,sourceKind.intValue(),sourceId,firstResult.intValue(),maxResults.intValue());
		ContentRelatedType relatedType = contentRelatedTypeManager.getContentRelatedTypeByName(relatedTypeName);
		request.setAttribute(returnContentListName,contentList);
		request.setAttribute(returnRelatedTypeName,relatedType);
	}catch(Exception e){
		e.printStackTrace();
	}
%>
<jsp:doBody />
